package net.cyue.web.easyquery.provider.db.mybatis.spring;

import net.cyue.web.easyquery.core.util.TaskUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

@Component
@MapperScan("net.cyue.web.easyquery.**")
public class SpringApplicationContextAwareMybatis implements ApplicationContextAware {

    private final Logger logger = org.slf4j.LoggerFactory.getLogger(this.getClass());

    @Override
    public void setApplicationContext(
        @NonNull ApplicationContext applicationContext
    ) throws BeansException {
        this.logger.info("设置 WebApplicationContext...");
        TaskUtil.runTask(MyBatisSpringProviderTaskType.SET_CONTEXT, applicationContext);
    }
}
